﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DE.Interfaces;
using UserDAL;

namespace MoviesDAL
{
    public class MovieAgent:IDEAgent
    {
        private MovieData data;
        private MovieDALHelper DALHelper;

        public IBaseEntityData Data
        {
            get
            {
                return data;
            }
            
            set
            {
                data = (MovieData)value;
            }
        }

        public int Create(IBaseEntityData data)
        {
            DALHelper = new MovieDALHelper();
            this.data = (MovieData)DALHelper.Create(data);
            return 1;
        }

        public void Update(IBaseEntityData data)
        {
            this.data = (MovieData)data;
            DALHelper.Update(this.data);
        }

        public void Delete(int id)
        {
            data = null;
            DALHelper.Delete(id);
        }

        public void Fetch(int id, object additions)
        {
           /* if (DALHelper==null)
                DALHelper = new MovieDALHelper();
            data=(MovieData)DALHelper.Fetch(id);
            * */
        }

        public int Validate(string one, string two, object additions)
        {
          //  return DALHelper.Validate(data);
            return 1;
        }

        public DataTable getMoviesLearning(int userid, int limit)
        {
            return MovieServices.getMoviesLearning(userid,limit);
        }

        public void linkUserMovie(int userid, int movieid, float rating)
        {
            MovieServices.linkUserMovie(userid,movieid,rating);
        }

        public void userRelationsRoutine(UserData userdata)
        {
            MovieServices.userRelationsRoutine(userdata.UserID, userdata.RequestedDistance);
        }

        public DataTable myRatings(int userid)
        {
            return MovieServices.myRatings(userid);
        }

        public DataTable friendRatings(int friendid,int myid)
        {
            return MovieServices.friendRatings(friendid,myid);
        }

        public DataTable GetTopGroupMovies(int userid,int nlimit)
        {
            return MovieServices.GetTopGroupMovies(userid,nlimit);
        } 
    }
}